package controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DAO.DAOFactory;
import DAO.FacilitiesDAO;
import DAO.NotFoundException;

import model.FacilitiesDTO;

/**
 * Servlet implementation class MakeABooking
 */
@WebServlet("/MakeABooking")
public class MakeABookingTypeFilter extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

    public MakeABookingTypeFilter() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		doProcess(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		doProcess(request,response);
	}
	protected void doProcess(HttpServletRequest request,HttpServletResponse response)
	        throws ServletException,IOException
	{
		ArrayList<FacilitiesDTO> facilitiesList=new ArrayList<FacilitiesDTO>();
		FacilitiesDAO fa=DAOFactory.loadInstance().getFacilitiesDAO();
		String type = request.getParameter("type");
//		String bbid=request.getSession().getAttribute("liuruigege").toString();
//		request.getSession().setAttribute("liurui", bbid);

		try {
			if ( type != null ) {
				facilitiesList=fa.FindByType(type);
				request.setAttribute("List",facilitiesList);
			}
			
		} catch (NotFoundException e)
		{
			e.printStackTrace();
		}
		
		RequestDispatcher rd=request.getRequestDispatcher("/UpdateBooking.jsp");
		try {
			rd.include(request, response);
			} 
		catch (ServletException e) {
			e.printStackTrace();
			} 
		catch (IOException e) {
			e.printStackTrace();
		}
		
		
		
	}
	

}
